<template>
    <div class="loginBox">
      <!-- logo -->
      <h1 class="logo">家谱管理系统</h1>
      <!-- 登录盒子 -->
      <el-form ref="loginFormRef" :model="loginForm" :rules="loginFormRules" label-width="0px" class="login_form">
        <!-- 账号 -->
        <el-form-item prop="username">
          <el-input v-model="loginForm.username" prefix-icon="el-icon-user"></el-input>
        </el-form-item>
        <!-- 密码 -->
        <el-form-item prop="password">
          <el-input v-model="loginForm.password" prefix-icon="el-icon-lock" type="password"></el-input>
        </el-form-item>
        <!-- 按钮 -->
        <el-form-item class="btns">
          <el-button type="primary" @click="login" round>登录</el-button>
          <el-button type="info" @click="resetLoginForm" round>重置账号密码</el-button>
        </el-form-item>
      </el-form>
    </div>

</template>

<script>
export default {
  data() {
    return {
      loginForm: {
        username: '',
        password: ''
      },
      loginFormRules: {
        username: [
          { required: true, message: '请输入用户名称', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    resetLoginForm() {
      this.$refs.loginFormRef.resetFields()
    },
    login() {
      this.$refs.loginFormRef.validate(valid => {
        if (!valid) return
        // const result = this.$http.post('login', this.loginForm)
        // console.log(result)
        if (this.loginForm.username === 'admin' && this.loginForm.password === '123456') {
          return this.$router.push('/home')
        } else {
          return this.$message.error('登陆失败')
        }
      })
    }
  }
}

</script>

<style lang="less" scoped>

#login-all{

position: fixed;
height: 100%;
width: 100%;
top: 0;
left: 0;
background-image: linear-gradient(
  90deg,
  rgb(33, 206, 206),
  purple
);
background-size: 400%;
animation: myanimation 10s infinite;

}
@keyframes myanimation{
0%{
  background-position: 0% 50%;
}
50%{
  background-position: 100% 50%;
}
100%{
  background-position: 0% 50%;
}
}
.bacstyle {
  background-color: #13c7e3;
  height: 100%;
}
.loginBox {
  background-color: #34495e;
  height: 300px;
  width: 450px;
  border-radius: 5px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.btns {
  display: flex;
  justify-content: flex-end;
}

.login_form {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding: 0 30px;
  box-sizing: border-box;
}

.logo {
  color: #09a8a8;
  border-radius: 5px;
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translate(-50%, -50%);
  padding: 10px 10px 10px;
  box-sizing: border-box;
}
</style>
